package com.catering.project.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.catering.common.annotation.Log;
import com.catering.common.core.controller.BaseController;
import com.catering.common.core.domain.AjaxResult;
import com.catering.common.enums.BusinessType;
import com.catering.project.domain.Dish2;
import com.catering.project.service.IDish2Service;
import com.catering.common.utils.poi.ExcelUtil;
import com.catering.common.core.page.TableDataInfo;

/**
 * 菜品图片信息展示Controller
 * 
 * @author cui
 * @date 2024-10-21
 */
@RestController
@RequestMapping("/project/dish2")
public class Dish2Controller extends BaseController
{
    @Autowired
    private IDish2Service dish2Service;

    /**
     * 查询菜品图片信息展示列表
     */
    @PreAuthorize("@ss.hasPermi('project:dish2:list')")
    @GetMapping("/list")
    public TableDataInfo list(Dish2 dish2)
    {
        startPage();
        List<Dish2> list = dish2Service.selectDish2List(dish2);
        return getDataTable(list);
    }

    /**
     * 导出菜品图片信息展示列表
     */
    @PreAuthorize("@ss.hasPermi('project:dish2:export')")
    @Log(title = "菜品图片信息展示", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Dish2 dish2)
    {
        List<Dish2> list = dish2Service.selectDish2List(dish2);
        ExcelUtil<Dish2> util = new ExcelUtil<Dish2>(Dish2.class);
        util.exportExcel(response, list, "菜品图片信息展示数据");
    }

    /**
     * 获取菜品图片信息展示详细信息
     */
    @PreAuthorize("@ss.hasPermi('project:dish2:query')")
    @GetMapping(value = "/{did}")
    public AjaxResult getInfo(@PathVariable("did") Long did)
    {
        return success(dish2Service.selectDish2ByDid(did));
    }

    /**
     * 新增菜品图片信息展示
     */
    @PreAuthorize("@ss.hasPermi('project:dish2:add')")
    @Log(title = "菜品图片信息展示", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Dish2 dish2)
    {
        return toAjax(dish2Service.insertDish2(dish2));
    }

    /**
     * 修改菜品图片信息展示
     */
    @PreAuthorize("@ss.hasPermi('project:dish2:edit')")
    @Log(title = "菜品图片信息展示", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Dish2 dish2)
    {
        return toAjax(dish2Service.updateDish2(dish2));
    }

    /**
     * 删除菜品图片信息展示
     */
    @PreAuthorize("@ss.hasPermi('project:dish2:remove')")
    @Log(title = "菜品图片信息展示", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dids}")
    public AjaxResult remove(@PathVariable Long[] dids)
    {
        return toAjax(dish2Service.deleteDish2ByDids(dids));
    }
}
